import axios from "axios";
import Vue from 'vue'
export default {
    /**
     * @description 获取专辑内容
     * @returns <AxiosPromise>
     */
    banner: function() { return axios.get('/banner?type=0') },
    album: {
        /**
         * @description 获取专辑内容
         * @data {id}
         * @returns <AxiosPromise>
         */
        album: function(data) {
            return axios({
                method: 'post',
                url: '/album',
                params: data
            })
        },
        /**
         * @description 专辑动态信息
         * @data {id}
         * @returns <AxiosPromise>
         */
        dynamic: function(data) {
            return axios({
                method: 'post',
                url: '/album/detail/dynamic',
                params: data
            })
        }
    },
    login: {
        /**
         * @description 手机登录
         * @data {phone,password,[countrycode,md5_password,captcha]}
         * @returns <AxiosPromise>
         */
        cellphone: function(data) {
            return axios({
                method: 'post',
                url: '/login/cellphone',
                params: data
            });
        },
        /**
         * @description 登录状态
         * @returns <AxiosPromise>
         */
        status: function() {
            return axios.post('/login/status' + '?timestamp=' + +new Date(), { cookie: Vue.prototype.getCookie('cookie') })
        }
    },
    user: {
        /**
         * @description 获取账号信息
         * @returns <AxiosPromise>
         */
        account: function() {
            return axios.get('/user/account', { cookie: Vue.prototype.getCookie('cookie') })
        },
        /**
         * @description 获取用户详情
         * @data {uid}
         * @returns <AxiosPromise>
         */
        detail: function(data) {
            return axios({
                method: 'post',
                url: '/user/detail',
                params: data
            });
        },
        /**
         * @description 获取用户歌单
         * @data {uid}
         * @returns <AxiosPromise>
         */
        playlist: function(data) {
            return axios({
                method: 'post',
                url: '/user/playlist',
                params: data
            });
        },
    },
    recommend: {
        /**
         * @description 获取每日推荐歌单(需要登录)
         * @returns <AxiosPromise>
         */
        resource: function() {
            return axios.post('/recommend/resource', { cookie: Vue.prototype.getCookie('cookie') })
        },
        /**
         * @description 获取每日推荐歌曲(需要登录)
         * @returns <AxiosPromise>
         */
        songs: function() {
            return axios.post('/recommend/songs', { cookie: Vue.prototype.getCookie('cookie') })
        }
    },
    personalized: {
        /**
         * @description 独家放送(入口列表)
         * @returns <AxiosPromise>
         */
        privatecontent: function() {
            return axios.post('/personalized/privatecontent', { cookie: Vue.prototype.getCookie('cookie') })
        },
        /**
         * @description 推荐mv
         * @returns <AxiosPromise>
         */
        mv: function() {
            return axios.post('/personalized/mv', { cookie: Vue.prototype.getCookie('cookie'), })
        },
        /**
         * @description 推荐电台
         * @returns <AxiosPromise>
         */
        djprogram: function() {
            return axios.post('/personalized/djprogram', { cookie: Vue.prototype.getCookie('cookie') })
        }
    },
    song: {
        /**
         * @description 推荐电台
         * @data {id,[br]} (br码率,默认设置了 999000 即最大码率,如果要 320k 则可设置为 320000,其他类推)
         * @returns <AxiosPromise>
         */
        url: function(data) {
            return axios({
                method: 'post',
                url: '/song/url',
                params: data
            })
        },
        /**
         * @description 获取歌曲详情
         * @data {ids} (支持多个 id, 用 , 隔开)
         * @returns <AxiosPromise>
         */
        detail: function(data) {
            return axios({
                method: 'post',
                url: '/song/detail',
                params: data
            })
        }
    },
    playlist: {
        /**
         * @description 获取歌单所有歌曲
         * @data {id,[limit,offset]}
         * @returns <AxiosPromise>
         */
        track: function(data) {
            return axios({
                method: 'post',
                url: '/playlist/track/all',
                params: data,
                data: { cookie: Vue.prototype.getCookie('cookie') }
            })
        },
        /**
         * @description 获取精品歌单
         * @data {[cat,limit,before]}
         * @returns <AxiosPromise>
         */
        highquality: function(data) {
            return axios({
                method: 'post',
                url: '/top/playlist/highquality',
                params: data
            })
        },
        /**
         * @description 获取歌单详情
         * @data {id}
         * @returns <AxiosPromise>
         */
        detail: function(data) {
            return axios({
                method: 'post',
                url: '/playlist/detail',
                params: data,
                data: { cookie: Vue.prototype.getCookie('cookie') }
            })
        },
        /**
         * @description 歌单详情动态(评论数,是否收藏,播放数)
         * @data {id}
         * @returns <AxiosPromise>
         */
        dynamic: function(data) {
            return axios({
                method: 'post',
                url: '/playlist/detail/dynamic',
                params: data
            })
        },

    }
}